<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/15 0015
 * Time: 9:23
 */

namespace Cohuna\Models;

use Phalcon\Mvc\Model;

class ModelBase extends Model
{
    public function initialize()
    {
        $this->setup([
            'notNullValidations'=>false
        ]);
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return static
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return static
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    public function getError()
    {
        $messages = $this->getMessages();

        if(count($messages) > 0){
            return $messages[0];
        }
        return null;
    }

}